using System;
using G3.State;

namespace G3.AI
{
    #region General types
    public enum DriverType { Neural, RuleBased, Hybrid, Human };

    public interface IDriver
    {
        Pair Think();           // return value: throttle and wheel values
        void Teach(int treshold);
        DriverType Type();
        void LoadProfile(String fileName);
        void SaveProfile(String fileName);
    }
    #endregion
    
    /*
    #region HumanDriver
    public class HumanDriver : IDriver
    {
        private double wheelPosition    = 0;
        private double throttlePosition = 0;
        private bool acceleration   = false;
        private bool braking        = false;
        private bool left           = false;
        private bool right          = false;
        private double HumanDriverAcceleration;
        private double HumanDriverBraking;
        private double HumanDriverEngineBraking;
        private double HumanDriverWheelSteering;
        private double HumanDriverWheelRetraction;

        public HumanDriver()
        {
            HumanDriverAcceleration     = int.Parse((String)Parameters.GetParameter("HumanDriverAcceleration"));
            HumanDriverBraking          = int.Parse((String)Parameters.GetParameter("HumanDriverBraking"));
            HumanDriverEngineBraking    = int.Parse((String)Parameters.GetParameter("HumanDriverEngineBraking"));
            HumanDriverWheelSteering    = int.Parse((String)Parameters.GetParameter("HumanDriverWheelSteering"));
            HumanDriverWheelRetraction  = int.Parse((String)Parameters.GetParameter("HumanDriverWheelRetraction"));
        }

        public Pair Think()
        {
            //Applying interactions
            if (acceleration)   throttlePosition += HumanDriverAcceleration;    //accelerating
            else                                                                //not...
            {
                //if (throttlePosition>) throttlePosition -= HumanDriverEngineBraking;
                //if (throttlePosition < 0) throttlePosition = 0;
            }

            if (braking)        throttlePosition -= HumanDriverBraking;         //braking

            if (left)           wheelPosition -= HumanDriverWheelSteering;      //steering left
            else if (right)     wheelPosition += HumanDriverWheelSteering;      //steering right
            else                                                                //retracting wheel to the centre
            {
                if (Math.Abs(wheelPosition) > HumanDriverWheelRetraction || wheelPosition == 0) wheelPosition = 0;
                else wheelPosition -= Math.Sign(wheelPosition)*HumanDriverWheelRetraction;
            }

            //Returning with the current positions
            return new Pair(throttlePosition, wheelPosition);
        }
        
        public DriverType Type()
        {
            return DriverType.Human;
        }

        public void HandleInteraction(System.Windows.Forms.Keys KeyCode, bool pushed)         //handling interaction idetified by a char which is sent by form, second parameter is true, if the key is pushed, and false if isn't
        {
            switch (KeyCode)
            {
                
                //case System.Windows.Forms.Keys.Up:      acceleration    = pushed; break;
                //case System.Windows.Forms.Keys.Space:   braking         = pushed; break;
                //case System.Windows.Forms.Keys.Left:    left            = pushed; break;
                //case System.Windows.Forms.Keys.Right:   right           = pushed; break;
                

                case System.Windows.Forms.Keys.W: acceleration = pushed; break;
                case System.Windows.Forms.Keys.S: braking = pushed; break;
                case System.Windows.Forms.Keys.A: left = pushed; break;
                case System.Windows.Forms.Keys.D: right = pushed; break;
            }
        }
    }
    #endregion

    #region HybridDriver
    public class HybridDriver : IDriver
    {
        private double deviation;           //Gauss
        private double prospectiveValue;    //Gauss

        private double[] weights;

        public HybridDriver()
        {
        }

        public Pair Think()
        {
            return new Pair(0,0);
        }

        public DriverType Type()
        {
            return DriverType.Hybrid;
        }

    }
    #endregion
    
    */
}